<%-- 
    Document   : saveTranslation
    Created on : Dec 13, 2009, 2:09:56 PM
    Author     : ayca
--%>

<%@page contentType="text/html" pageEncoding="UTF-8" language="java" import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="edu.boun.cmpe.elele.cotrans.dbOperations.DbOperations"%>


<%
String text= request.getParameter("text");
String transID = request.getParameter("transId");

System.out.println("trans id = " +transID);

//System.out.println("text = " +text);
text="bla bla bla";
transID="2";
String DRIVER = "org.gjt.mm.mysql.Driver";
Class.forName(DRIVER).newInstance();


Connection con=null;
ResultSet rs=null;
Statement stmt=null;

try{
String url="jdbc:mysql://localhost/CoTrans?user=cotrans&password=cotrans";

int i=1;
con=DriverManager.getConnection(url);
stmt=con.createStatement();
int a;

rs=stmt.executeQuery("select path from TranslationInfo where transID='"+transID+"' ");

String fileName = rs.getString(1);
System.out.println("file name: " + fileName);
rs.close();
stmt.close();
con.close();

try {
    PrintWriter pw = new PrintWriter(new FileOutputStream(fileName));
    pw.println(text);
    //clean up
    pw.close();
} catch(IOException e) {
   out.println(e.getMessage());
}
}
catch(Exception e){
System.out.println(e.getMessage());
}



%>